<?php
/**
 * Created by PhpStorm.
 * User: 24390
 * Date: 2020/7/9
 * Time: 20:50
 */

use OSS\OssClient;
use OSS\Core\OssException;

class Aliyun
{
    public  $accessKeyId = "LTAI4Fqoh7UpphQbDHQMLXEA";
// 阿里云主账号AccessKey拥有所有API的访问权限，风险很高。强烈建议您创建并使用RAM账号进行API访问或日常运维，请登录 https://ram.console.aliyun.com 创建RAM账号。
    public  $accessKeySecret = "8KZ49ngzSOYalKemvZCnHLLPu0uF4k";// Endpoint以杭州为例，其它Region请按实际情况填写。
    public  $endpoint = "http://oss-cn-hangzhou.aliyuncs.com";
    public  $bucket = "hdam";// 存储空间名称

    public function upload($file_name,$file_path)
    {

        try {
            $ossClient = new OssClient($this->accessKeyId, $this->accessKeySecret, $this->endpoint);
            $res = $ossClient->uploadFile($this->bucket, "image/".$file_name, $file_path);
            return $res;
        } catch (OssException $e) {
            print $e->getMessage();

        }

    }
}